# -*- coding: utf-8 -*-
from blog_setting import create_app
from myblog.models import db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

app = create_app()

# flask-script的操作，支持命令python manage.py runserver启动项目
manager = Manager(app)

# flask-migrate的操作，它基于flask-script，需要联合使用，第一个参数是Flask的实例，第二个参数是Sqlalchemy数据库实例
Migrate(app, db)
# manager是Flask-Script的实例，这条语句在flask-Script中添加一个db命令，相当于自定制脚本命令，支持python manage.py db init
manager.add_command('db', MigrateCommand)


if __name__ == '__main__':
    manager.run()